package www.wxwnb.clerk.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by dingguanxu on 2017/9/9.
 */

public class TimeUtil {

    public static String dateOrString2Timestamp(String time) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = null;
        try {
            parse = simpleDateFormat.parse(time);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return String.valueOf(parse.getTime());
    }

    public static String timestamp2DateOrString(String timestamp) {
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
        Long time = new Long(timestamp);
        Date date = new Date(time);
        return simpleDateFormat.format(date);
    }

    public static String timestamp2DateOrString(long timestamp) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date(timestamp);
        return simpleDateFormat.format(date);
    }

}
